<?php
/*
 * 通过用户id和活动状态获取相应的活动列表
 * 需要查找两个部分，一个是自己创建的活动，另一部分是别人创建的活动
 */
require_once("../data/db_connection.php");
require_once("../constants.php");
require_once("../Utils.php");

$db = new db();

$user_id = getFinalValue($_POST[PARAM_USER_ID]);
$event_state = getFinalValue($_POST[PARAM_EVENT_STATE]);

$arr = array();
$sql = "SELECT * FROM pTableEventInfo WHERE pEventState = " .
			$event_state . " and _id in ( 
			SELECT pEventId From pTableUserEvent WHERE pUserId = " . 
			$user_id ." and pIfConfirmInvite in (0, 2))";
if ($result = $db->query($sql)) { 
	while($row = $result->fetch_assoc()){
		$arr[] = $row;
	}
}
$str = json_encode($arr);
echo json_encode($str);
?>
